<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <meta content="" name="description"/>
    <meta content="webthemez" name="author"/>
    <title>登录</title>

    <!-- jQuery Js -->
    <script src="assets/js/jquery-1.10.2.js"></script>
    <!-- layer Js -->
    <script src="assets/js/layer.js"></script>
    <!-- base Js -->
    <script src="assets/js/base.js"></script>
    <style>
        body, html, head {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
            background-color: #4D4D4D;
        }

        .title_div {
            position: fixed;
            top: 20%;
            left: 35%;
            width: 30%;
            font-size: 24px;
            color: white;
            padding: 10px;
            text-align: center
        }

        .login_div {
            position: fixed;
            top: 45%;
            left: 35%;
            width: 30%;
            border: 1px solid white;
            padding: 10px;
            color: white;

        }

        .login_div span {
            font-size: 20px;
            position: absolute;
            margin: 20px 10px;
        }

        .login_group {
            margin-top: 5%;
            text-align: center;
        }

        .login_group label {
            font-size: 18px;
            letter-spacing: 5px;
        }

        .login_group input {
            width: 70%;
        }

        .login_group button {
            width: 85%;
            height: 30px;
            font-size: 18px;
            border-radius: 10px;
            background-color: #337AEB;
            border: none;
            color: white;
        }
    </style>
</head>

<body>
<div class="title_div">
    <img src="assets/img/logo.png" style="width: 100%;">
    <p>后台管理系统</p>
</div>
<div class="login_div">
    <img src="assets/img/none.png" style="width: 60px">
    <span>用户登录</span>
    <div class="login_group">
        <label for="login_name">账号:</label>
        <input id="login_name">
    </div>
    <div class="login_group">
        <label for="login_password">密码:</label>
        <input type="password" id="login_password">
    </div>
    <div class="login_group">
        <button id="submit">提交</button>
    </div>

</div>


</body>
<script>
    window.onload = function () {
        $('#submit').click(function () {
            var _name = $('#login_name').val();
            var _pwd = $('#login_password').val();
            if (!_name) {
                layer.msg("请输入您的账号!", {time: 3000})
            } else if (!_pwd) {
                layer.msg("请输入您的密码!", {time: 3000})
            } else {
                $.get("http://118.178.59.93:8080/Motocycle/api/v1/admins", {
                    mobile: _name,
                    password: _pwd
                }, function (data) {
                    try {
                        var obj = JSON.parse(data);
                        if (obj.code == 0) {
                            layer.msg("登录成功,正在为您跳转,请稍后...");
                            storage_admin_id = obj.data.admin_id;
                            storage.setItem("_storage_admin_id", storage_admin_id);
                            setTimeout(function () {
                                window.location.href = "user.html"
                            }, 3000)
                        }
                    } catch (e) {
                        layer.msg(data.msg, {time: 3000})
                    }


                })
            }
        });
    };


</script>
</html>